import asyncio
import threading


@asyncio.coroutine
def hello():
    print('Hello World! %s' % threading.current_thread())

    r = yield from asyncio.sleep(1)

    print('Hello again! %s' % threading.current_thread())

# py 3.5 的新语法
async def hi():
    print('Hi')
    r = await asyncio.sleep(1)
    print('Hi It\'s me again!')


loop = asyncio.get_event_loop()
tasks = [hello(), hello(), hi(), hi()]
loop.run_until_complete(asyncio.wait(tasks))

loop.close()